﻿using MongoDB.Bson.Serialization.Attributes;

namespace IMServer.Models.Message
{
    [BsonDiscriminator("GroupChatMessage")]
    public class GroupChatMessage:ChatMessage
    {
        [BsonElement("groupId")]
        public string GroupId { get; set; } = null!;

        [BsonElement("groupName")]
        public string GroupName { get; set; } = null!;

        [BsonElement("groupAvatar")]
        public string GroupAvatar { get; set; } = null!;

        public  override string ToJson()
        {
            var messageData = new
            {
                ChatType,
                MessageId,
                SenderId,
                SenderName,
                SenderAvatar,
                ReceiverId,
                GroupId,
                GroupName,
                GroupAvatar,
                Content,
                MessageType,
                Timestamp,
                IsRead
            };
            return System.Text.Json.JsonSerializer.Serialize(messageData);
        }
    }
}
